#define _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>
#include<math.h>

int cnt;

int main() {

    int a;
    scanf("%d", &a);

    for (int i = 0; i <= a; i ++ ) {
        int p = i * i;

        int t = i, c = 1;
        while (t > 9) {
            t = t / 10;
            c ++;
        }

        p = p % (int)pow(10, c);

        if (p == i) cnt ++;
    }
    printf("%d", cnt);
    return 0;
}